package com.jqb.pattern.composite;

import java.util.ArrayList;
import java.util.List;
/**
 * 组合模式
 * @author Dong
 *
 */
public class Composite implements Component {

	List<Component> list = new ArrayList<Component>();
	@Override
	public void doSth() {
		for(Component component:list){
			component.doSth();
		}
	}
	
	public void add(Component component){
		list.add(component);
	} 

	public void remove(Component component){
		list.remove(component);
	}
	
	public List<Component> getAll(){
		return this.list;
	}
}
